import state from '../store/state.js';
// 开发环境不使用懒加载, 因为懒加载页面太多的话会造成webpack热更新太慢
const _import = require('./import-' + process.env.NODE_ENV);

function getProps(route) {
  return route.query;
}

// 系统生成路由
const routers = [
  {
    path: '/login',
    component: _import('login/index'),
    name: 'login',
    props: getProps,
    desc: '登录'
  },
  {
    path: '/',
    component: _import('login/index'),
    name: 'root'
  },
  {
    path: '/startPage',
    component: _import('flash/index'),
    name: 'startPage',
    props: getProps,
    desc: '欢迎页'
  },
  {
    path: '/courseLogin',
    component: _import('courseLogin/index'),
    name: 'courseLogin',
    props: getProps,
    desc: '课程登录'
  },
  {
    path: '/custom/login',
    component: _import('customLogin/index'),
    name: 'customLogin',
    props: getProps,
    desc: '认证用户登录'
  },
  {
    path: '/enterprise/login',
    component: _import('enterpriseLogin/index'),
    name: 'enterpriseLogin',
    props: getProps,
    desc: '企业用户登录'
  },
  {
    path: '/course/main',
    component: _import('course/index'),
    name: 'course',
    props: getProps,
    desc: '用户主页'
  },
  {
    path: '/challenge',
    component: _import('front/challenge/index'),
    name: 'frontChallenge',
    props: getProps,
    desc: '闯关模式'
  },
  {
    path: '/challenge/scene',
    component: _import('front/scene/index'),
    name: 'frontScene',
    props: getProps,
    desc: '场景模式'
  },
  {
    path: '/material',
    component: _import('front/material/index'),
    name: 'frontMaterial',
    props: getProps,
    desc: '资料查询'
  },
  {
    path: '/video/view',
    component: _import('front/videoview/index'),
    name: 'videoview',
    props: getProps,
    desc: '视频播放'
  },
  {
    path: '/text/view',
    component: _import('front/textview/index'),
    name: 'textview',
    props: getProps,
    desc: '文本浏览'
  },
  {
    path: '/exam/main',
    component: _import('front/examMain/index'),
    name: 'examMain',
    props: getProps,
    desc: '考试主页'
  },
  {
    path: '/exam/rank',
    component: _import('front/examRank/index'),
    name: 'examRank',
    props: getProps,
    desc: '考试排行'
  },
  {
    path: '/exam/view',
    component: _import('front/examview/index'),
    name: 'examview',
    props: getProps,
    desc: '考试界面'
  },
  {
    path: '/exam/result',
    component: _import('front/examresult/index'),
    name: 'examresult',
    props: getProps,
    desc: '考试结果'
  },
  {
    path: '/exam/detail',
    component: _import('front/examDetail/index'),
    name: 'examDetail',
    props: getProps,
    desc: '考试结果详情'
  },
  {
    path: '/doc/view',
    component: _import('front/docview/index'),
    name: 'docview',
    props: getProps,
    desc: '文档界面'
  },
  {
    path: '/evluate',
    component: _import('front/evluate/index'),
    name: 'evluateView',
    props: getProps,
    desc: '评估界面'
  },
  {
    path: '/evluate/result',
    component: _import('front/evluateresult/index'),
    name: 'evluateResultView',
    props: getProps,
    desc: '评估结果界面'
  },
  {
    path: '/main',
    component: _import('layout/index'),
    name: 'main',
    props: getProps,
    redirect: {
      name: 'welcome'
    },
    meta: {
      title: '主页',
      showOnly: true
    },
    children: [
      {
        path: 'formsBizChallengeModule',
        component: _import('biz/formsBizChallengeModule/index'),
        name: 'formsBizChallengeModule',
        meta: { title: '闯关管理' }
      },
      {
        path: 'formsBizEvluateSurvey',
        component: _import('biz/formsBizEvluateSurvey/index'),
        name: 'formsBizEvluateSurvey',
        meta: { title: '问卷管理' }
      },
      {
        path: 'formsBizExamPaper',
        component: _import('biz/formsBizExamPaper/index'),
        name: 'formsBizExamPaper',
        meta: { title: '试卷管理' }
      },
      {
        path: 'formsBizExam',
        component: _import('biz/formsBizExam/index'),
        name: 'formsBizExam',
        meta: { title: '考试管理' }
      },
      {
        path: 'formBizEvluateRank',
        component: _import('biz/formsBizEvluateRank/index'),
        name: 'formBizEvluateRank',
        meta: { title: '评价记录管理' }
      },
      {
        path: 'formsBizExamRank',
        component: _import('biz/formsBizExamRank/index'),
        name: 'formsBizExamRank',
        meta: { title: '考试排名管理' }
      },
      {
        path: 'formsBizChallenge',
        component: _import('biz/formsBizChallenge/index'),
        name: 'formsBizChallenge',
        meta: { title: '闯关管理' }
      },
      {
        path: 'formsBizMaterial',
        component: _import('biz/formsBizMaterial/index'),
        name: 'formsBizMaterial',
        meta: { title: '资料管理' }
      },
      {
        path: 'formsBizSubject',
        component: _import('biz/formsBizSubject/index'),
        name: 'formsBizSubject',
        meta: { title: '题库管理' }
      },
      {
        path: 'formSysUser',
        component: _import('upms/formSysUser/index'),
        name: 'formSysUser',
        meta: { title: '用户管理' }
      },
      {
        path: 'formSysDept',
        component: _import('upms/formSysDept/index'),
        name: 'formSysDept',
        meta: { title: '部门管理' }
      },
      {
        path: 'formSysRole',
        component: _import('upms/formSysRole/index'),
        name: 'formSysRole',
        meta: { title: '角色管理' }
      },
      {
        path: 'formSysDataPerm',
        component: _import('upms/formSysDataPerm/index'),
        name: 'formSysDataPerm',
        meta: { title: '数据权限管理' }
      },
      {
        path: 'formSysMenu',
        component: _import(
          state.supportColumn ? 'upms/formSysMenu/formSysColumnMenu' : 'upms/formSysMenu/index'
        ),
        name: 'formSysMenu',
        meta: { title: '菜单列表' }
      },
      {
        path: 'formSysDict',
        component: _import('upms/formDictManagement/index'),
        name: 'formSysDict',
        meta: { title: '字典管理' }
      },
      {
        path: 'formSysPermCode',
        component: _import('upms/formSysPermCode/index'),
        name: 'formSysPermCode',
        meta: { title: '权限字管理' }
      },
      {
        path: 'formSysPerm',
        component: _import('upms/formSysPerm/index'),
        name: 'formSysPerm',
        meta: { title: '权限资源管理' }
      },
      {
        path: 'formSysOperationLog',
        component: _import('upms/formSysOperationLog/index'),
        name: 'formSysOperationLog',
        meta: { title: '操作日志' }
      },
      {
        path: 'formSysLoginUser',
        component: _import('upms/formSysLoginUser/index'),
        name: 'formSysLoginUser',
        meta: { title: '在线用户' }
      },
      // 岗位模块路由配置
      {
        path: 'formSysPost',
        component: _import('upms/formSysPost/index'),
        name: 'formSysPost',
        meta: { title: '岗位管理' }
      },
      {
        path: 'formSysDeptPost',
        component: _import('upms/formSysDeptPost/index'),
        name: 'formSysDeptPost',
        props: getProps,
        meta: { title: '设置部门岗位' }
      },
      // 在线表单模块路由配置
      {
        path: 'formOnlineDblink',
        component: _import('online/formOnlineDblink/index'),
        name: 'formOnlineDblink',
        props: getProps,
        meta: { title: '数据库链接' }
      },
      {
        path: 'formOnlineDict',
        component: _import('online/formOnlineDict/index'),
        name: 'formOnlineDict',
        props: getProps,
        meta: { title: '在线表单字典管理' }
      },
      {
        path: 'formOnlinePage',
        component: _import('online/index'),
        name: 'formOnlinePage',
        props: getProps,
        meta: { title: '在线表单管理' }
      },
      {
        path: 'onlineForm',
        component: _import('online/OnlinePageRender/index'),
        name: 'onlineForm',
        props: getProps,
        meta: { title: '在线表单' }
      },
      {
        path: 'welcome',
        component: _import('welcome/index'),
        name: 'welcome',
        meta: { title: '欢迎' }
      }
    ]
  },
  // 第三方接入路由
  {
    path: '/thirdParty',
    name: 'thirdParty',
    props: getProps,
    component: _import('thirdParty/index'),
    children: [
      // 在线表单部分
      {
        path: 'thirdOnlineForm',
        name: 'thirdOnlineForm',
        props: getProps,
        component: _import('online/OnlinePageRender/index')
      },
      {
        path: 'thirdOnlineEditForm',
        name: 'thirdOnlineEditForm',
        props: getProps,
        component: _import('online/OnlinePageRender/OnlineEditForm/index')
      },
      {
        path: 'thirdFormOnlineDict',
        name: 'thirdFormOnlineDict',
        props: getProps,
        component: _import('online/formOnlineDict/index')
      },
      {
        path: 'thirdEditOnlineDict',
        name: 'thirdEditOnlineDict',
        props: getProps,
        component: _import('online/formOnlineDict/editOnlineDict')
      },
      {
        path: 'thirdOnlinePage',
        name: 'thirdOnlinePage',
        props: getProps,
        component: _import('online/index')
      },
      {
        path: 'thirdEditOnlinePage',
        name: 'thirdEditOnlinePage',
        props: getProps,
        component: _import('online/editOnlinePage/index')
      },
      {
        path: 'thirdEditOnlineForm',
        name: 'thirdEditOnlineForm',
        props: getProps,
        component: _import('online/editOnlinePage/editOnlineForm')
      },
      {
        path: 'thirdEditPageDatasource',
        name: 'thirdEditPageDatasource',
        props: getProps,
        component: _import('online/editOnlinePage/editOnlinePageDatasource')
      },
      {
        path: 'thirdEditPageRelation',
        name: 'thirdEditPageRelation',
        props: getProps,
        component: _import('online/editOnlinePage/editOnlinePageDatasourceRelation')
      },
      {
        path: 'thirdSetOnlineTableColumnRule',
        name: 'thirdSetOnlineTableColumnRule',
        props: getProps,
        component: _import('online/editOnlinePage/setOnlineTableColumnRule')
      },
      {
        path: 'thirdEditVirtualColumnFilter',
        name: 'thirdEditVirtualColumnFilter',
        props: getProps,
        component: _import('online/editOnlinePage/editVirtualColumnFilter')
      },
      {
        path: 'thirdEditTableColumn',
        name: 'thirdEditTableColumn',
        props: getProps,
        component: _import('online/formDesign/editTableColumn')
      },
      {
        path: 'thirdEditCustomFormOperate',
        name: 'thirdEditCustomFormOperate',
        props: getProps,
        component: _import('online/formDesign/components/EditCustomFormOperate')
      },
      {
        path: 'thirdEditFormField',
        name: 'thirdEditFormField',
        props: getProps,
        component: _import('online/formDesign/components/EditFormField')
      },
      {
        path: 'thirdEditDictParamValue',
        name: 'thirdEditDictParamValue',
        props: getProps,
        component: _import(
          'online/formDesign/components/CustomWidgetDictSetting/editDictParamValue'
        )
      },
      {
        path: 'thirdEditOnlineTableColumn',
        name: 'thirdEditOnlineTableColumn',
        props: getProps,
        component: _import(
          'online/formDesign/components/OnlineTableColumnSetting/editOnlineTableColumn'
        )
      },
      {
        path: 'thirdEditOnlineTabPanel',
        name: 'thirdEditOnlineTabPanel',
        props: getProps,
        component: _import('online/formDesign/components/OnlineTabPanelSetting/editOnlineTabPanel')
      },
      {
        path: 'thirdOnlineDblink',
        name: 'thirdOnlineDblink',
        props: getProps,
        component: _import('online/formOnlineDblink/index')
      },
      {
        path: 'thirdEditOnlineDblink',
        name: 'thirdEditOnlineDblink',
        props: getProps,
        component: _import('online/formOnlineDblink/editOnlineDblink')
      },
      // 通用
      {
        path: 'thirdEditDictParamValue2',
        name: 'thirdEditDictParamValue2',
        props: getProps,
        component: _import(
          'components/WidgetAttributeSetting/components/CustomWidgetDictSetting/editDictParamValue',
          'online'
        )
      },
      {
        path: 'thirdEditOnlineTableColumn2',
        name: 'thirdEditOnlineTableColumn2',
        props: getProps,
        component: _import(
          'components/WidgetAttributeSetting/components/OnlineTableColumnSetting/editOnlineTableColumn',
          'online'
        )
      },
      {
        path: 'thirdEditOnlineTabPanel2',
        name: 'thirdEditOnlineTabPanel2',
        props: getProps,
        component: _import(
          'components/WidgetAttributeSetting/components/OnlineTabPanelSetting/editOnlineTabPanel',
          'online'
        )
      },
      {
        path: 'thirdSelectDept',
        name: 'thirdSelectDept',
        props: getProps,
        component: _import('DeptSelect/deptSelectDlg', 'components')
      },
      {
        path: 'thirdSelectUser',
        name: 'thirdSelectUser',
        props: getProps,
        component: _import('UserSelect/userSelectDlg', 'components')
      },
      {
        path: 'thirdSelectData',
        name: 'thirdSelectData',
        props: getProps,
        component: _import('components/OnlineCustomDataSelect/dataSelectDlg', 'online')
      },
      {
        path: 'thirdEditCustomEvent',
        name: 'thirdEditCustomEvent',
        props: getProps,
        component: _import('components/CustomEventSetting/editCustomEvent', 'online')
      }
    ]
  }
];

export default routers;
